import { Button } from 'antd';
import {WeaDialog ,WeaNewScroll,WeaLocaleProvider,WeaTableEdit,WeaTable} from 'ecCom';
import {observer} from "mobx-react";
import {toJS} from 'mobx';
const getLabel = WeaLocaleProvider.getLabel;

@observer
class ContributionSortDialog extends React.Component {
    constructor(props) {
        super(props);
    }

    shouldComponentUpdate(nextProps,nextState){
        return true;
    }
 
    render() {
        const { store } = this.props;
        const { visible3, setVisible3, defColumns1, columnDatas1 } = store;
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@sxyh38`}
                title={'采用稿件排序'}
                visible={visible3}
                buttons={this.getButtons()}
                icon="icon-coms-ModelingEngine"
                iconBgcolor="#217346"
                onCancel={()=>{setVisible3(false)}}
                style={{width:'1000px', height:'600px'}}
            >
                <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@as008c`} height={"100%"}>
                    <WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTableEdit@ocqr2y`}
                        columns={toJS(defColumns1)}
                        dataSource={toJS(columnDatas1)}
                        onDrop={this.onChange}
                        draggable={true}
                        ref="table"
                        rowKey={"id"}
                    />
                </WeaNewScroll>
            </WeaDialog>
        )
    }

    onChange = (datas) => {
        const { store } = this.props;
        const { setColumnDatas1 } = store;
        setColumnDatas1(datas);
    }

    getButtons(){
        const { store } = this.props;
        const { setVisible3, submitDatas1 } = store;
        let btnArr = []; 
        btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@fjjgvg@close`}  type="primary" onClick={()=>{
            submitDatas1();
        }}>{getLabel(615,"提交")}</Button>)  
        btnArr.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@fjjgvg@close`}  type="primary" onClick={()=>setVisible3(false)}>{getLabel(309,"关闭")}</Button>)  
        return btnArr;
    }
   
}

export default ContributionSortDialog;